package main

import (
	"fmt"
	"io"
	"net"
	"net/http"
	"net/rpc"
)

type Rpctest int

func (r *Rpctest) GetInfo(argType int, reply *int) error {

	fmt.Println("打印端发送过来的内容为：", argType)

	*reply += 1
	return nil

}

func test(w http.ResponseWriter, r *http.Request) {
	io.WriteString(w, "hello go")
}
func main() {

	//页面的请求
	http.HandleFunc("/test", test)

	{
		//实例化对象
		rt := new(Rpctest)
		//服务注册一个对象
		rpc.Register(rt)
		rpc.HandleHTTP()
	}
	listen, err := net.Listen("tcp", ":8888")
	if err != nil {
		fmt.Println("网络错误")
	}
	http.Serve(listen, nil)
}
